<?php
/**
 * @version SVN: $Id: orderdefault.php 1174 2010-04-26 14:51:33Z elkuku $
 * @package    EasyCreator
 * @subpackage	Views
 * @author		EasyJoomla {@link http://www.easy-joomla.org Easy-Joomla.org}
 * @author		Nikolai Plath (elkuku) {@link http://www.nik-it.de NiK-IT.de}
 * @author		Created on 11-Sep-2008
 * @license    GNU/GPL, see JROOT/LICENSE.php
 */

// no direct access
defined( '_JEXEC' ) or die( ';)' );

JHTML::_('behavior.mootools');

?>
<style>
li.handle {
	cursor: move;
}
li.handle:hover {
	background-color: yellow;
}
.ecr_code {
	border: 1px dotted grey;
	background-color: #F2F2FF;
}
</style>
<script type="text/javascript">
function addElement()
{
	// Get the value into the input text field
	var elementText=document.getElementById('newElement').value;
	if(elementText=="")
	{
		// Show an error message if the field is blank;
		document.getElementById('msg').style.display="block";
		document.getElementById('msg').innerHTML = JSLNG_INSERT_A_DESCRIPTION
	}
	else
	{
		elementText = "<span style='color: orange;'>#"+elementText+"</span><input type='hidden' name='langfile[]' value='#"+elementText+"' />";

		// Show a message if the element has been added;
		document.getElementById('msg').style.display="block";
		document.getElementById('msg').innerHTML = "Elemend added!";
		// Clean input field
		document.getElementById('newElement').value="";
		var item1 = new Element('li', {'class': 'handle'}).setHTML(elementText).inject($('orderMe'));
		var sortList = new Sortables($('orderMe'));
	}
}//function
</script>

<div class="ecr_code">

<?php
$isHeader = true;
$started = false;
foreach ($this->default_language as $lang)
{
	if( $lang->key == '#' )
	{
		$dString = $lang->value;
		if( $isHeader )
		{
			echo '<input type="hidden" name="langfile[]" value="'.$dString.'" />';
			echo '<span style="color: green;">'.$dString.'</span><br />';
		}
		else
		{
			$dfString = '<span style="color: orange;">'.$dString.'</span>';
		}
	}
	else
	{
		$isHeader = false;
		if( ! $started )
		{
			?>
			<ul id="orderMe" style="list-style-type: none;">
			<?php
			$started = true;
		}

		if( $lang->value )
		{
			$dString = $lang->key.'='.$lang->value;

			$dfString = '<span style="color: blue;">'.$lang->key.'</span>';
			$dfString .= '<strong style="color: red;"> = </strong>';
			$dfString .= ecrHTML::cleanHTML($lang->value);
		}
		else
		{
			$dString = '';
			$dfString = '&nbsp;';
		}
	}

	if( ! $isHeader )
	{
		?>
		<li class="handle">
			<?php
			echo '<input type="hidden" name="langfile[]" value="'.$dString.'" />';
			echo $dfString;
			?>
		</li>
	<?php
	}
}//foreach
?>
</ul>

</div>
<p>
#<input name="newElement" id="newElement" type="text" value=""/>
<span class="ecr_button img icon-16-add" onclick="addElement();"><?php echo JText::_('Add Comment'); ?></span>
</p>
<div id="msg"></div>

<script type="text/javascript" language="javascript">
	var sortList = new Sortables($('orderMe'));
</script>